home *** CD-ROM | disk | FTP | other *** search
/ OpenGL Superbible (2nd Edition) / OpenGL SuperBible e2.iso / tools / FLTK-1.0.6 / src / forms_fselect.cxx < prev    next >
Encoding:
C/C++ Source or Header  |  1999-01-07  |  2.1 KB  |  66 lines

  1. //
  2. // "$Id: forms_fselect.cxx,v 1.4 1999/01/07 19:17:45 mike Exp $"
  3. //
  4. // Forms file selection routines for the Fast Light Tool Kit (FLTK).
  5. //
  6. // Copyright 1998-1999 by Bill Spitzak and others.
  7. //
  8. // This library is free software; you can redistribute it and/or
  9. // modify it under the terms of the GNU Library General Public
  10. // License as published by the Free Software Foundation; either
  11. // version 2 of the License, or (at your option) any later version.
  12. //
  13. // This library is distributed in the hope that it will be useful,
  14. // but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  16. // Library General Public License for more details.
  17. //
  18. // You should have received a copy of the GNU Library General Public
  19. // License along with this library; if not, write to the Free Software
  20. // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
  21. // USA.
  22. //
  23. // Please report all bugs and problems to "fltk-bugs@easysw.com".
  24. //
  25.  
  26. // Emulate the Forms file chooser using the fltk file chooser.
  27.  
  28. #include <FL/forms.H>
  29. #include <string.h>
  30.  
  31. static char fl_directory[1024];
  32. static const char *fl_pattern;  // assummed passed value is static
  33. static char fl_filename[256];
  34.  
  35. char* fl_show_file_selector(const char *message,const char *dir,
  36.                 const char *pat,const char *fname) {
  37.   if (dir && dir[0]) strncpy(fl_directory,dir,1023);
  38.   if (pat && pat[0]) fl_pattern = pat;
  39.   if (fname && fname[0]) strncpy(fl_filename,fname,255);
  40.   char *p = fl_directory+strlen(fl_directory);
  41.   if (p > fl_directory && *(p-1)!='/'
  42. #ifdef WIN32
  43.       && *(p-1)!='\\' && *(p-1)!=':'
  44. #endif
  45.       ) *p++ = '/';
  46.   strcpy(p,fl_filename);
  47.   const char *q = fl_file_chooser(message,fl_pattern,fl_directory);
  48.   if (!q) return 0;
  49.   strcpy(fl_directory, q);
  50.   p = (char *)filename_name(fl_directory);
  51.   strcpy(fl_filename, p);
  52.   if (p > fl_directory+1) p--;
  53.   *p = 0;
  54.   return (char *)q;
  55. }
  56.  
  57. char*    fl_get_directory() {return fl_directory;}
  58.  
  59. char*    fl_get_pattern() {return (char *)fl_pattern;}
  60.  
  61. char*    fl_get_filename() {return fl_filename;}
  62.  
  63. //
  64. // End of "$Id: forms_fselect.cxx,v 1.4 1999/01/07 19:17:45 mike Exp $".
  65. //
  66.